package com.starhub;

import io.github.asleepyfish.annotation.EnableChatGPT;
import org.apache.ibatis.annotations.Mapper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableAsync
@EnableScheduling
@SpringBootApplication(exclude = {FreeMarkerAutoConfiguration.class})
@EnableChatGPT
@ComponentScan(basePackages = {
        "com.starhub",
        "com.starhub.common.exception",// 确保异常处理器被扫描到
})
@ServletComponentScan(basePackages = "com.starhub")
@ImportResource(locations = {"classpath*:application.xml"})
@MapperScan(value = "com.starhub", annotationClass = Mapper.class)
// 移除单个properties文件加载，改为使用PropertiesConfig类动态加载所有properties文件
public class SpringbootAiApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(SpringbootAiApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(SpringbootAiApplication.class);
    }

}
